package spring_introduction;

import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test4 {
    public static void main(String[] args) {

        try (
                ClassPathXmlApplicationContext context =
                        new ClassPathXmlApplicationContext("applicationContext2.xml")) {

            Dog myDog = context.getBean("myPet", Dog.class);
            myDog.setName("Belka");
            Dog myDog2 = context.getBean("myPet", Dog.class);
            myDog2.setName("Strelka");

            System.out.println(myDog.getName());
            System.out.println(myDog2.getName());

            System.out.println(myDog);
            System.out.println(myDog2);
            System.out.println(myDog == myDog2);
            System.out.println(myDog.equals(myDog2));
            System.out.println(myDog.hashCode() == myDog2.hashCode());
        }
    }
}
